<?php
function loginUser($username, $password) {
    $isValidUser = false;
    
    if($username == 'admin' && $password == '123456') {
        $isValidUser = true;
        
        $_SESSION['user']['id']         = 1;
        $_SESSION['user']['username']   = 'admin';
        $_SESSION['user']['role']       = 5;
    }
    
    return $isValidUser;
}


function isValidAdmin() {
    if($_SESSION['user']['role'] == 5) {
        return true;
    }
    else {
        return false;
    }
}


function adminCheck($returnTo) {
    if(isValidAdmin()) {
        return true;
    }
    else {
        header('location: authentication.php?returnTo='.urlencode($returnTo));
        exit;
    }
}
?>